package calorie.com.calorie.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.lxh.baselibray.base.XActivity;
import com.lxh.baselibray.dialog.AlertDialog;
import com.lxh.baselibray.util.SizeUtils;
import com.lxh.baselibray.view.TitleView;

import butterknife.BindView;
import butterknife.OnClick;
import calorie.com.calorie.R;

/**
 * 充币
 * Created by ThinkPad on 2018-11-28.
 */

public class CoinChargingActivity extends XActivity {

    //确定按钮
    @BindView(R.id.btn_confirm)
    Button btn_confirm;
    //币种类型（CAL/VIT）
    @BindView(R.id.tv_CurrencyType)
    TextView tv_CurrencyType;
    @BindView(R.id.titleView)
    TitleView titleView;
    @BindView(R.id.tv_MoneyAddrs)
    TextView tvMoneyAddrs;
    @BindView(R.id.iv_charge_qrcode)
    ImageView ivChargeQRCode;
    private String type="激活券";


    @Override
    public void initData(Bundle savedInstanceState) {
        tvMoneyAddrs.setText("0x9D408b1e2350D9f795B57B54ADC361700006A53b");
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_wallet_coin_charging;
    }

    @OnClick({R.id.btn_confirm, R.id.tv_CurrencyType})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_confirm:
                Intent intent = new Intent(CoinChargingActivity.this, InputHashActivity.class);
                intent.putExtra(InputHashActivity.TYPE,type);
                startActivity(intent);
                break;
            case R.id.tv_CurrencyType:
             showTypeDialog();
                break;
        }
    }

    AlertDialog typeDialog = null;
    public void showTypeDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .addDefaultAnimation()
                .setCancelable(true)
                .setText(R.id.tv_one,"CAL")
                .setText(R.id.tv_two,"激活券")
                .setContentView(R.layout.dialog_type_select)
                .fromBottom(true)
                .setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT, SizeUtils.dp2px(context, 80))
                .setOnClickListener(R.id.tv_one, v -> {
                    type="CAL";
                    tv_CurrencyType.setText("CAL");
                    ivChargeQRCode.setImageResource(R.drawable.icon_cal_qr_code);
                    typeDialog.dismiss();
                }).setOnClickListener(R.id.tv_two, v -> {
                    type="激活券";
                    tv_CurrencyType.setText("激活券");
                    ivChargeQRCode.setImageResource(R.drawable.icon_vit_qr_code);
                    typeDialog.dismiss();
                });
        typeDialog = builder.create();
        typeDialog.show();
    }
}
